<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title th:text="${questionDTO.title}"></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <link rel="stylesheet" type="text/css" href="/css/bootstrap.min.css"/>
    <link rel="stylesheet" type="text/css" href="/editormd/editormd.css"/>
    <!-- 引入fontawesome字体图标 -->
    <link rel="stylesheet" type="text/css" href="/fontawesome/css/all.css"/>
    <!-- 自定义样式 -->
    <link rel="stylesheet" type="text/css" href="/css/bbs.css"/>
    <script type="application/javascript" src="/js/jquery-3.4.1.min.js"></script>
    <script type="application/javascript" src="/editormd/editormd.min.js"></script>
    <script type="application/javascript" src="/editormd/marked.min.js"></script>
    <script type="application/javascript" src="/editormd/prettify.min.js"></script>
    <script type="application/javascript" src="/js/bootstrap.min.js"></script>
    <script type="application/javascript" src="/js/bootstrap.bundle.min.js"/>
    <script type="application/javascript" th:src="@{/js/bbs.js}"></script>
    <script type="application/javascript" th:src="@{/js/moment.js}"></script>
</head>
<body>
<!-- 引入顶部工具栏 -->
<div th:replace="/top::topBar"></div>
<div class="container main" style="background-color: white">
    <div class="row">
        <div class="col-lg-9 col-md-9 col-sm-9 col-xs-12">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <h3><span th:text="${questionDTO.title}"></span></h3>
                <span class="questionDetail">
                作者：<span th:text="${questionDTO.user.name}"></span>  |
                阅读数：<span th:text="${questionDTO.viewCount}"></span>  |
                发布时间：<span th:text="${#dates.format(questionDTO.gmtCreate,'yyyy-MM-dd HH:mm')}"></span>
            </span>
                <hr>
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12"id="test-markdown-view">
                    <textarea style="display:none;" th:text="${questionDTO.description}"></textarea>
                </div>
                <script type="text/javascript">
                    $(function () {
                        editormd.markdownToHTML("test-markdown-view", {});
                    });
                </script>
                <hr>
                <div>
                    <span th:each="tag:${questionDTO.tag.split(',')}">
                        <span class="badge badge-pill badge-info"><i class="fas fa-tags" th:text="${tag}"></i></span>
                    </span>
                </div>
                <hr>
                <span>
                <a style="color: #999;font-size: 13px" th:href="@{'/profile/publish/'+${questionDTO.id}}"
                   th:if="${session.user !=null && session.user.id == questionDTO.creator}"><span
                        class="fas fa-edit"></span>编辑</a>
            </span>
                <hr>
            </div>
            <!-- 回复 -->
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <h5>[[${questionDTO.commentCount}]]个回复</h5>
                <hr>
                <div class="media commentList" th:each="commentDTO : ${commentDTOList}">
                    <img th:src="${commentDTO.user.avatarUrl}" class="mr-3 rounded littleImg"
                         alt="...">
                    <div class="media-body" style="padding-top: 5px">
                        <h5 class="mt-0" th:text="${commentDTO.user.name}"></h5>
                        <span th:text="${commentDTO.content}"></span>
                        <div class="commentMenu">
                            <span class="far fa-thumbs-up"></span>
                            <span class="far fa-comment-alt" th:data-id="${commentDTO.id}" onclick="changeColor(this)"
                                  data-toggle="collapse" th:href="'#'+comment-+${commentDTO.id}"></span>
                            <span th:text="${commentDTO.commentCount}"></span>
                            <span class="float-right"
                                  th:text="${#dates.format(commentDTO.gmtCreate,'yyyy-MM-dd HH:mm')}"></span>
                        </div>
                        <div class="collapse" th:id="comment-+${commentDTO.id}" style="margin-bottom: 5px"
                             id="collapseExample">
                            <!--<div class="card card-body" style="margin-bottom: 5px;margin-top: 5px">
                                Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad
                                squid. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt
                                sapiente
                                ea proident.
                            </div>-->
                            <input type="text" class="form-control" id="exampleInputEmail1" style="margin-bottom: 5px"
                                   placeholder="请输入评论内容..." th:id="input-+${commentDTO.id}">
                            <button type="button" class="btn btn-success float-right" onclick="comment(this)"
                                    th:data-id="${commentDTO.id}">评论
                            </button>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" id="commentSection">
                <h5>提交回复</h5>
                <hr>
                <div class="media">
                    <img th:src="${questionDTO.user.avatarUrl}" class="mr-3 rounded littleImg"
                         alt="...">
                    <div class="media-body" style="padding-top: 5px">
                        <h5 class="mt-0" th:text="${questionDTO.user.name}"></h5>
                    </div>
                </div>
                <input type="hidden" class="comment-parentId" name="parentId" th:value="${questionDTO.id}">
                <textarea class="form-control comment-content" id="comment-content" rows="3"
                          style="margin: 10px 0px"></textarea>
                <button type="button" class="btn btn-success btn-comment float-right" onclick="postComment()">回复
                </button>
            </div>
        </div>
        <div class="col-lg-3 col-md-3 col-sm-3 col-xs-12">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <h4>发起人</h4><br>
                <div class="media">
                    <img th:src="${questionDTO.user.avatarUrl}" class="mr-3 rounded littleImg"
                         alt="...">
                    <div class="media-body">
                        <h5 class="mt-0" th:text="${questionDTO.user.name}"></h5>
                        </span>
                    </div>
                </div>
            </div>
            <br>
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <h4>相关问题</h4>
                <ul style="list-style: none;padding-left: 0px;">
                    <li th:each="question : ${questionDTOList}">
                        <a th:href="@{'/profile/questions/'+${question.id}}" th:text="${question.title}"></a>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</div>
</body>
</html>